package kreiseZeichnen;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JComponent;
import javax.swing.JFrame;

public class KreiseZeichnen extends JFrame{
	public static void main(String[] args) {
		new KreiseZeichnen();
	}
	
	KreiseZeichnen(){
		setSize(500,500);
		add(new JComponent(){
			public void paintComponent(Graphics g){
				drawCircleClassic(g,getWidth()/2,getHeight()/2,getWidth()/8,Color.red,Color.yellow,Color.green,Color.blue);
			}
		});
		setVisible(true);
	}
	
	public static double F(double x, double y, double r){
		return x*x+y*y-r*r;
	}
	
	public void drawCircleClassic(Graphics g, int x0, int y0, int r, Color cNorth, Color cEast, Color cSouth, Color cWest){
		int y = 0;
		double x = r;
		final int r_2 = r*r;
		while(y<=x){
			g.drawLine(x0,y0,(int)Math.rint(x),y);
			++y;
			if(F(x-0.5,y,r)>0)
				--x;
			System.out.println("Drawing Point ("+x+"|"+y+")");
		}
	}
}
